package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-07-19
 * Time: 23:06
 */

/*class login{
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public void logInfo(String userName, String passWord){
        if(!this.userName.equals(userName)){
            System.out.println("用户名错误");
            return;
        }

        if(!this.passWord.equals(passWord)){
            System.out.println("密码错误");
            return;
        }


        System.out.println("登录成功");
    }
}*/


class login{
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public void logInfo(String userName, String passWord)
            throws UserNameExpection,
            PassWordExpection{
        if(!this.userName.equals(userName)) {
            throw new UserNameExpection("用户名错误异常");

        }

        if(!this.passWord.equals(passWord)){
          throw new PassWordExpection("密码错误异常");
        }


        System.out.println("登录成功");
    }
}


public class Test {
    public static void main(String[] args) {
        login login = new login();
        login.setUserName("zhagnsah");
        login.setPassWord("123");
        try {
            login.logInfo("zhagzsnsah","123");
        }catch (UserNameExpection e){
            e.printStackTrace();
        }catch (PassWordExpection e){
            e.printStackTrace();
        }finally {

        }

    }
}
